package com.yoso;


import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Objects;


/**
 * 启动类
 * @author shizejin
 * @date 2023/11/27 09:44
 */
@Slf4j
@SpringBootApplication
@EnableAsync
public class WebApplication {

    public static void main(String[] args) throws UnknownHostException {

        final ConfigurableApplicationContext application = SpringApplication.run(WebApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        final String applicationName = Objects.requireNonNull(env.getProperty("spring.application.name")).toUpperCase();
        String path = Objects.toString(env.getProperty("server.servlet.context-path"), "/");
        log.info("\n----------------------------------------------------------\n\t" +
                "Application " + applicationName + " is running! Access URLs:\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "\n\t" +
                "External Swagger: \thttp://" + ip + ":" + port + path + "doc.html\n" +
                "----------------------------------------------------------");
    }
}
